import {request} from '/@/utils/service';
import {UserPageQuery, AddReq, EditReq, InfoReq} from '@fast-crud/fast-crud';

export const apiPrefix = '/api/system/menu/';

export function lazyLoadMenu(id: String) {
    return request({
        url: '/api/spider/info/agent',
        method: 'get',
        params: {
            key: id,
            pageSize: 20033,
        }
    });
}


export function menuMoveUp(obj: AddReq) {
    return request({
        url: apiPrefix + 'move_up/',
        method: 'post',
        data: obj,
    });
}

export function menuMoveDown(obj: AddReq) {
    return request({
        url: apiPrefix + 'move_down/',
        method: 'post',
        data: obj,
    });
}

export function getjournalArticleNum(id: BigInt) {
    return request({
        url: '/api/journal/info/journalArticleNum',
        method: 'get',
        params: {
            id: id,
        }
    });
}


export function getimpactFactor() {
    return request({
        url: '/api/spider/info/random',
        method: 'get',
    });
}

// 辅助函数：构建请求体
function buildRequestBody(id: BigInt, years: number[]) {
    const body: any = {
        id: id,  // 始终包含 id 参数
        limit: 1,
    };
    // 如果 years 不是 [0]，则添加 years 参数
    if (JSON.stringify(years) !== JSON.stringify([0])) {
        body.years = years;
    }
    return body;
}

export function getinstitutionArticleNum(id: BigInt, years: number[]) {
    const body = buildRequestBody(id, years);

    //console.log(body);

    return request({
        url: '/api/journal/info/institutionArticleNum',
        method: 'post',  // 改为 POST 请求
        data: body       // 请求体中的数据
    });
}

export function getSubjectNum(id: BigInt, years: number[]) {
    const body = buildRequestBody(id, years);

    return request({
        url: '/api/journal/info/subjectNum',
        method: 'post',  // 改为 POST 请求
        data: body       // 请求体中的数据
    });
}

export function getAuthorArticleNum(id: BigInt, years: number[]) {
    console.log(id,years)
    const body = buildRequestBody(id, years);

    return request({
        url: '/api/journal/info/authorArticleNum',
        method: 'post',  // 改为 POST 请求
        data: body       // 请求体中的数据
    });
}

export function getKeywordNum(id: BigInt, years: number[]) {
    const body = buildRequestBody(id, years);

    return request({
        url: '/api/journal/info/journalArticleThemes',
        method: 'post',  // 改为 POST 请求
        data: body       // 请求体中的数据
    });
}
